package com.team.six.bluecatshop.service;

import com.team.six.bluecatshop.domain.History;
import com.team.six.bluecatshop.mapper.HistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HistoryServiceImpl implements HistoryService {
    @Autowired
    private HistoryMapper historyMapper;


    @Override
    @Transactional
    public void add(History history) {
        historyMapper.insert(history);
    }

    @Override
    @Transactional
    public void remove(String id) {
        historyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public History findById(String id) {
        History history=historyMapper.selectByPrimaryKey(id);
        return history;
    }

    @Override
    public List<History> findAll() {
        List<History> historyList = historyMapper.findAll();
        return historyList;
    }

    @Override
    public History findHistoryByProductId(String id) {
        return historyMapper.findByProductId(id);
    }

    @Override
    public List<History> findHistoryByIndentId(String id) {
        List<History> history = historyMapper.findByIndentId(id);
        return history;
    }

    @Override
    @Transactional
    public void updateByPrimaryKey(History history) {
        historyMapper.updateByPrimaryKeySelective(history);
    }
}
